// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import topbar from './components/Bar/TopBar' // 导入子组件
import leftsidebar from './components/Bar/LeftSideBar' // 导入子组件
import uploadbar from './components/Bar/UploadBar' // 导入子组件

import cookies from 'vue-cookies'
Vue.prototype.$cookies = cookies; //配置时候prototype.$这里的名字自己定义不是固定是cookie
Vue.config.productionTip = false
import '@/permistion' //导入白名单
import axios from '../config/axios'

Vue.component('topbar', topbar)
Vue.component('leftsidebar', leftsidebar)
Vue.component('uploadbar', uploadbar)


Vue.prototype.$api = 'http://47.97.218.145:8000'
/* eslint-disable no-new */

// import axios from 'axios'
// router.beforeEach((to, from, next) => {
//   if (to.name == "Signin") {
//     next(); // 避免递归的行为
//   } else {
//     let token = localStorage.getItem("token");
//     if (token) {
//       //访问服务器缓存数据，判断当前token是否失效
//       axios({
//         url: "http://123.57.61.168:8000" + "/api/user/virify/", // 校验token有效期
//         method: "post",
//         data: {
//           token: token
//         },
//         withCredentials: true
//       }).then(res => {
//         if (res.data.code == 0) {
//           next();
//         } else {
//           next("/signin");
//         }
//       });
//     } else {
//       next("/signin");
//     }
//   }
// })

new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
})
